package com.english.service.impl;

import com.english.entity.CustomerService;
import com.english.mapper.CustomerServiceMapper;
import com.english.service.CustomerServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional
public class CustomerServiceServiceImpl implements CustomerServiceService {

    @Autowired
    private CustomerServiceMapper customerServiceMapper;

    @Override
    public CustomerService getCustomerService() {
        return customerServiceMapper.selectOne(null);
    }

    @Override
    public boolean updateCustomerService(CustomerService customerService) {
        customerService.setId(1L);
        customerService.setUpdateTime(new Date());
        
        // 如果记录不存在则插入，否则更新
        CustomerService existing = customerServiceMapper.selectById(1L);
        if (existing == null) {
            return customerServiceMapper.insert(customerService) > 0;
        } else {
            return customerServiceMapper.updateById(customerService) > 0;
        }
    }
} 